package io.awen.modules.sign.controller;

import io.awen.common.utils.DateUtils;
import io.awen.common.utils.PageUtils;
import io.awen.common.utils.R;
import io.awen.modules.sign.entity.SignContainerEntity;
import io.awen.modules.sign.entity.SignContainerRealtimeLiquidLevelEntity;
import io.awen.modules.sign.qo.SignContainerQo;
import io.awen.modules.sign.service.SignContainerRealtimeLiquidLevelService;
import io.awen.modules.sign.service.SignContainerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;


/**
 * 容器信息表
 *
 * @author liu.wen
 * @email liu.wen@qq.com
 * @date 2022-08-10 00:47:08
 */
@Api(tags = {"实时液位"})
@RestController
@RequestMapping("sign/signContainerRealtimeLevel")
public class SignContainerRealtimeLiquidLevelController {

    @Autowired
    private SignContainerRealtimeLiquidLevelService signContainerRealtimeLiquidLevelService;

    /**
     * 容器实时值
     */
    @PostMapping("/realList") //sign/signContainerRealtimeLevel/realList
    public R realList(HttpServletRequest request) {
        String contanerId = request.getParameter("contanerId");
        String startDatetime = request.getParameter("startDatetime");
        String endDatetime = request.getParameter("endDatetime");

        if (StringUtils.isBlank(startDatetime)){
            startDatetime = DateUtils.format(new Date(),"yyyy-MM-dd")+" 00:00:00";
        }
        if (StringUtils.isBlank(endDatetime)){
            endDatetime = DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss");
        }

        List<SignContainerRealtimeLiquidLevelEntity> data = signContainerRealtimeLiquidLevelService.getAllByDate(contanerId, startDatetime, endDatetime);
        return R.ok().put("list",data);
    }

}
